﻿using System.Collections.Generic;
using HK.Editor.Common.Protocol;
using HK.Editor.GUIEx.Protocol.Pagination;

namespace HK.Editor.GUIEx.Protocol.Drawer
{
    /// <summary>
    /// 事件委托定义 : 检索按钮点击事件
    /// </summary>
    /// <param name="iSearchKey">检索Key</param>
    public delegate void OnSearchBtnClicked(string iSearchKey);
    
    /// <summary>
    /// 接口 : GUI绘制器 - 分页面板
    /// </summary>
    public interface IPaginationDrawer : IGUIDiyDrawer
    {
        /// <summary>
        /// 数组标志位
        /// </summary>
        bool IsArray { get; }
        
        /// <summary>
        /// 总个数
        /// </summary>
        int TotalSize { get; }
        
        /// <summary>
        /// 显示个数
        /// </summary>
        int VisibleSize { get; }

        /// <summary>
        /// Footer可见标志位
        /// </summary>
        bool FooterVisible { get; }

        /// <summary>
        /// 开始坐标偏移 - Y轴
        /// </summary>
        float StartPosYOffset { get; }
        
        /// <summary>
        /// 取得高度 - Header
        /// </summary>
        float GetHeaderHeight();
        
        /// <summary>
        /// 取得高度 - Footer
        /// </summary>
        float GetFooterHeight();
        
        /// <summary>
        /// 分页信息
        /// </summary>
        IPagination Pagination { get; }

        /// <summary>
        /// 重置页索引
        /// </summary>
        void ResetIndex();

        /// <summary>
        /// 取得当前分页可视范围
        /// </summary>
        /// <param name="iElementNum">元素个数</param>
        /// <param name="oStartIndex">开始索引(从0开始)</param>
        /// <param name="oEndIndex">结束索引s</param>
        /// <returns>当前分页可视范围</returns>
        bool GetVisibleRange(int iElementNum, out int oStartIndex, out int oEndIndex);
        
#region Events

        /// <summary>
        /// 展开/缩进
        /// </summary>
        /// <param name="iIsExpanded">true:展开; false:缩进;</param>
        void Expand(bool iIsExpanded);
        
        /// <summary>
        /// 检索按钮点击事件
        /// </summary>
        OnSearchBtnClicked OnSearched { get; }

#endregion

#region SearchBar

        /// <summary>
        /// 显示检索Bar
        /// </summary>
        bool SearchBarVisible { get; }

        /// <summary>
        /// 检索Key
        /// </summary>
        string SearchKey { get; }

        /// <summary>
        /// 检索中标志位
        /// </summary>
        bool Searching { get; }

        /// <summary>
        /// 显示检索Bar
        /// </summary>
        /// <param name="iVisible">true:显示; false:不显示;</param>
        void ShowSearchBar(bool iVisible);
        
#endregion

#region Sort

        /// <summary>
        /// 排序
        /// </summary>
        /// <param name="iAscending">true:升序; false:倒序;</param>
        void Sort(bool iAscending);

#endregion

#region Selection



#endregion

    }

    /// <summary>
    /// 接口 : GUI绘制器 - 分页面板 - SerializedProperty
    /// </summary>
    public interface ISpPaginationDrawer : IPaginationDrawer
    {
        /// <summary>
        /// 列表Element的Key
        /// <para>* 用来排序，检索等用的Key</para>
        /// </summary>
        string ElementKey { get; }
    }
    
    /// <summary>
    /// 接口 : GUI绘制器 - 分页面板 - string
    /// </summary>
    public interface IStrPaginationDrawer : IPaginationDrawer
    {
        /// <summary>
        /// 字符串列表
        /// </summary>
        List<string> List { get; }
    }

    /// <summary>
    /// 委托事件定义 : I/O对象追加
    /// <param name="iTargets">追加目标列表</param>
    /// </summary>
    public delegate int OnIoAssetsAdded(IReadOnlyList<string> iTargets);
    
    /// <summary>
    /// 接口 : GUI绘制器 - 分页面板 - I/O对象
    /// <para>* 文件+文件夹</para>
    /// </summary>
    public interface IIoPaginationDrawer : IStrPaginationDrawer
    {
        /// <summary>
        /// 浏览选项
        /// </summary>
        IOBrowse BrowseOptions { get; }
        
        /// <summary>
        /// 追加回调
        /// </summary>
        OnIoAssetsAdded AddElements { get; }
    }
}
